package org.jeecg.modules.act.service.impl;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.act.entity.ActMatter;
import org.jeecg.modules.act.entity.ActMatterValue;
import org.jeecg.modules.act.mapper.ActMatterMapper;
import org.jeecg.modules.act.service.IActMatterService;
import org.jeecg.modules.act.service.IActUsermatterService;
import org.jeecg.modules.act.vo.ActMatterValueVo;
import org.jeecg.modules.act.vo.ActMatterVo;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 活动事项表
 * @Author: jeecg-boot
 * @Date: 2019-09-04
 * @Version: V1.0
 */
@Service
public class ActMatterServiceImpl extends ServiceImpl<ActMatterMapper, ActMatter> implements IActMatterService {

    @Resource
    private ActMatterMapper matterMapper;

    @Override
    public Result<List<Map<String, Object>>> findAllByActId(String actId,String userId) {
        Result<List<Map<String, Object>>> result = new Result<>();
        List<Map<String, Object>> listByActId = matterMapper.listByActId(actId,userId);
        if (CollectionUtils.isEmpty(listByActId)) {
            result.setSuccess(false);
            result.setCode(1);
            result.setMessage("操作失败");
        } else {
            result.setSuccess(true);
            result.setResult(listByActId);
        }
        return result;
    }

    @Override
    public List<ActMatterVo> listByActId(String actId) {
        return matterMapper.findByActId(actId);
    }

    @Override
    public List<ActMatterValueVo> findKV(String userId,String actId) {
        return matterMapper.findKV(userId,actId);
    }
}
